﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Liang.Device.Camera.Dll
{
    /// <summary>
    /// 中瀛鑫摄像头DLL
    /// </summary>
    static class WisionDll
    {
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        [DllImport("KsCamera_ZYX.dll")]
        public static extern int KsCamera_ZYX_Init();

        /// <summary>
        /// 注销
        /// </summary>
        /// <returns></returns>
        [DllImport("KsCamera_ZYX.dll")]
        public static extern int KsCamera_ZYX_Cleanup();

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="hWnd">播放窗口句柄</param>
        /// <param name="strDevName">设备名称</param>
        /// <param name="strIPAddr">ip地址</param>
        /// <param name="nPort">端口号</param>
        /// <param name="strUserName">账号</param>
        /// <param name="strPassword">密码</param>
        /// <param name="nTimeOut">登录超时</param>
        /// <returns></returns>
        [DllImport("KsCamera_ZYX.dll")]
        public static extern IntPtr KsCamera_ZYX_Login(IntPtr hWnd,
            string strDevName,
            string strIPAddr,
            int nPort,
            string strUserName,
            string strPassword,
            UInt32 nTimeOut);

        /// <summary>
        /// 注销登录
        /// </summary>
        /// <param name="hDevID">摄像头句柄</param>
        /// <returns></returns>
        [DllImport("KsCamera_ZYX.dll")]
        public static extern int KsCamera_ZYX_LogOut(IntPtr hDevID);

        /// <summary>
        /// 实时播放
        /// </summary>
        /// <param name="hDevID">摄像头句柄</param>
        /// <param name="nDeviceChannel">通道号</param>
        /// <param name="hMsgWnd">消息窗口句柄</param>
        /// <param name="hPlayWnd">播放窗口句柄</param>
        /// <param name="nCodecType">编码模式</param>
        /// <param name="nImageSize">分辨率</param>
        /// <returns></returns>
        [DllImport("KsCamera_ZYX.dll")]
        public static extern int KsCamera_ZYX_RealPlay(
            IntPtr hDevID,
            int nDeviceChannel,
            IntPtr hMsgWnd,
            IntPtr hPlayWnd,
            int nCodecType,
            int nImageSize);

        /// <summary>
        /// 停止实时播放
        /// </summary>
        /// <param name="hDevID">摄像头播放句柄</param>
        /// <returns></returns>
        [DllImport("KsCamera_ZYX.dll")]
        public static extern int KsCamera_ZYX_StopRealPlay(IntPtr hDevID);

        /// <summary>
        /// 抓拍
        /// </summary>
        /// <param name="hDevID">摄像头播放句柄</param>
        /// <param name="strImageFile">图片存储路径</param>
        /// <param name="bWait"></param>
        /// <returns></returns>
        /// 
        [DllImport("KsCamera_ZYX.dll")]
        public static extern int KsCamera_ZYX_CaptureImage(
            IntPtr hDevID,
            string strImageFile,
            int bWait);
    }
}
